﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using YasharEl.Infrastructure.ResourcesManagement;

namespace YasharEl.Infrastructure.ProcessEngine
{
    [Serializable]
    public class ProcessCancellationDeniedException : TranslatedDomainModelException
    {
        private const string ProcessCancellationDenied = "ProcessCancellationDenied";
        private readonly Guid _workflowInstanceId;

        public Guid WorkflowInstanceId
        {
            get { return _workflowInstanceId; }
        }

        public ProcessCancellationDeniedException(IResourceManager resourceManager, Guid workflowInstanceId)
            : base
             (
                resourceManager,
                string.Format(
                    resourceManager.GetString(ProcessCancellationDenied, CultureInfo.GetCultureInfo("en")),
                    workflowInstanceId
                )
             )
        {
            _workflowInstanceId = workflowInstanceId;
        }

        protected ProcessCancellationDeniedException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        protected override string ExceptionMessageResourceKey
        {
            get { return ProcessCancellationDenied; }
        }

        public override string TranslatedMessage
        {
            get
            {
                return string.Format(resourceManager.GetString(ProcessCancellationDenied), WorkflowInstanceId);
            }
        }
    }
}
